home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
17 Bit Software 6: Level 6
/
17 Bit - Level 6 (1998)(Epic Marketing)[!].iso
/
quartz
/
q1082.dms
/
q1082.adf
/
src.lzh
/
Fig
/
blink.c
< prev
next >
Wrap
C/C++ Source or Header
|
1991-07-18
|
2KB
|
101 lines
/*
* FIG : Facility for Interactive Generation of figures
*
* Copyright (c) 1988 by Supoj Sutanthavibul (supoj@sally.UTEXAS.EDU)
* Febuary 1988.
*
* %W% %G%
*/
#include "fig.h"
static int cursor_on, cursor_is_moving;
static int cursor_x, cursor_y;
static int blink();
int (*erase)()=0;
int (*draw)()=0;
static struct itimerval blink_timer;
turn_on_blinking_cursor(draw_cursor, erase_cursor, x, y, sec, usec)
int (*draw_cursor)();
int (*erase_cursor)();
int x, y;
long sec, usec;
{
draw = draw_cursor;
erase = erase_cursor;
cursor_is_moving = 0;
cursor_x = x;
cursor_y = y;
#ifndef AMIGA
blink_timer.it_interval.tv_usec = usec;
blink_timer.it_interval.tv_sec = sec;
blink_timer.it_value.tv_usec = usec;
blink_timer.it_value.tv_sec = sec;
#endif AMIGA
draw(x, y);
cursor_on = 1;
#ifndef AMIGA
#define SIGALRM 0
#define ITIMER_REAL 1
signal(SIGALRM, blink);
setitimer(ITIMER_REAL, &blink_timer, (struct itimerval *)0);
/*
(void) notify_set_itimer_func(&me, blink, ITIMER_REAL, &blink_timer, 0);
*/
#endif AMIGA
}
turn_off_blinking_cursor()
{
if (!draw) return;
if (cursor_on) erase(cursor_x, cursor_y);
draw = erase = NULL;
#ifndef AMIGA
blink_timer.it_interval.tv_usec = 0;
blink_timer.it_interval.tv_sec = 0;
blink_timer.it_value.tv_usec = 0;
blink_timer.it_value.tv_sec = 0;
setitimer(ITIMER_REAL, &blink_timer, (struct itimerval *)0);
/*
(void) notify_set_itimer_func(&me, blink, ITIMER_REAL, 0, 0);
*/
#endif AMIGA
}
static
blink()
{
if (cursor_is_moving) return(0);
if (cursor_on) {
erase(cursor_x, cursor_y);
cursor_on = 0;
}
else {
draw(cursor_x, cursor_y);
cursor_on = 1;
}
return(0);
}
timerfunc()
{
static int count=5;
if (--count>0) return;
count=5;
if (!draw) return 0;
blink();
}
move_blinking_cursor(x, y)
int x, y;
{
cursor_is_moving = 1;
if (cursor_on) erase(cursor_x, cursor_y);
cursor_x = x;
cursor_y = y;
draw(cursor_x, cursor_y);
cursor_on = 1;
cursor_is_moving = 0;
}